//
//  JMAlbum.m
//  ImagePicker
//
//  Created by Jamin on 2018/10/15.
//  Copyright © 2018 jamin. All rights reserved.
//

#import "JMIPAlbum.h"
#import "JMPhotosManager.h"
#import "JMImagePickerDefines.h"
@import Photos;
@implementation JMIPAlbum

- (instancetype)initWithCollection:(id)Collection result:(id)result {
    if (self = [super init]) {
        PHFetchResult *fetchResult = (PHFetchResult *)result;
        PHAssetCollection *c = (PHAssetCollection *)Collection;
        self.result = result;
        _count = fetchResult.count;
        _name = c.localizedTitle;
    }
    return self;
}


- (void)fetchCurrentAssetsCompletion:(void (^)())completion {
    
    kDefWeakSelf;
    [JMPhotosManager getAssetsFromFetchResult:self.result completion:^(NSArray<JMIPAsset *> *assets) {
        weakSelf.models = assets;
        !completion ?: completion();
    }];
}


@end
